1194D - 1-2-K Game - CodeForces Solution


games math *1700

Please click on ads to support us..

C++ Code:

//I'm confused
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define odrse tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define odrmse tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;*/
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<long long,long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<int> vi;
typedef vector<pair<long long, long long>> vll;
typedef vector<pli> vli;
typedef vector<pil> vil;
typedef vector<string> vs;
#define prqu priority_queue
typedef priority_queue<ll> pql;
typedef priority_queue<int> pqi;
typedef priority_queue<pll> pqll;
typedef priority_queue<pli> pqli;
typedef priority_queue<pil> pqil;
typedef map<ll,int> mli;
typedef map<ll,ll> mll;
typedef map<int,int> mii;
typedef map<int,ll> mil;
typedef map<pll,ll> mlll;

#define ff(i,a,b) for(ll i=a;i<=ll(b);i++)
#define rep(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ffd(i,a,b,x) for(ll i=a;i<=b;i+=x)
#define repd(i,a,b,x) for(ll i=a;i>=b;i-=x)
#define fff(i,v) for(auto i : v)
#define ffi(i,v) for(ll i = 0; i <= v.sz-1; i++)
#define repi(i,v) for(ll i = v.sz-1; i >= 0; i--)
#define ffp(x1,x2,v) for(auto [x1,x2] : v)
#define ffit(it,v) for(auto it = v.begin() ; it != v.end(); it++)
#define all(x) x.begin(),x.end()
#define en cout<<endl;
#define eren cerr<<endl;
#define pb push_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define ft front()
#define bk back()
#define clr clear()
#define ppb pop_back
#define sqr(x) (x)*(x)
#define gcd(a,b) __gcd(a,b)
#define sz size()
#define rsz resize
#define reset(x,val) memset((x),(val),sizeof(x))
#define mtset multiset
#define cid(x) x = " "+x;
#define sstr substr
#define ins insert
#define ers erase
#define emp empty()
#define maxelm max_element
#define minelm min_element
#define ctn continue
#define rtn return
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define yesno(c) (c? "YES":"NO")
#define outyesno(c) { cout<<yesno(c)<<endl; rtn; }
#define nortn {cout<<"NO"<<endl; rtn; }
#define yesrtn { cout<<"YES"<<endl; rtn; }
#define valrtn(x) { cout<<x<<endl; rtn; }
#define x first
#define y second

#define ffmask(mask,n) for(ll mask = 1; mask <= (1<<n)-1; mask++)
//#define ffbit1(x,mask) for(x = mask;x > 0; x -= x & (-x))
#define lastbit1(x) x & (-x)
#define getbit(n,x) (1<<x)&n
#define cntbit1(x) __builtin_popcountll(x)
#define cntbit0(x) __builtin_clzll(x)

#define lwb lower_bound
#define upb upper_bound

#define tcT template <class T
#define tcTU tcT, class U
template<typename T1, typename T2> bool maxi(T1& a, T2 b) {if (a < b) {a = b; return 1;} else return 0;}
template<typename T1, typename T2> bool mini(T1& a, T2 b) {if (a > b) {a = b; return 1;} else return 0;}
template<typename T1, typename T2> bool minswap(T1& a, T2 b) {if (a > b) {swap(a,b); return 1;} else return 0;}
template<typename T1, typename T2> bool maxswap(T1& a, T2 b) {if (a < b) {swap(a,b); return 1;} else return 0;}
template <class T> using mprqu = priority_queue<T, vector<T>, greater<T>>;

#define debug(X) {auto _X=(X); cerr << "L" << __LINE__ << ": " << #X << " = " << (_X) << endl;}
#define err(x) cerr << #x << " = " << (x) << '\n'
#define arrerr(it1, it2) for(auto it = it1; it != it2; it++) cerr << *it << " "; eren;
#define dot cerr<<"." << endl;

inline void inp(){} template<typename F, typename... R> inline void inp(F &f,R&... r){cin>>f;inp(r...);}
inline void out(){} template<typename F, typename... R> inline void out(F f,R... r){cout<<f;out(r...);}

const ll cr = 2e5 + 7;
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll inf = 1e18 + 7;
const ll base = 311;
const ldb pi = (ldb)3.1415926535897932384626433832795;
const string Yes = "Yes";
const string No = "No";
const string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
bool mem2;

#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FILE(s) freopen(s".INP","r",stdin);freopen(s".OUT","w",stdout);
#define FILEinp(s) freopen(s".INP","r",stdin);
#define Get1700rate int32_t main()
#define y1 tlapluvnth
#define y2 zz16102007
#define left nthnevaluvtlap
#define right tlapstillluvnth
#define j1 yy16102007
#define j2 xx16102007

ll rdr(ll l, ll r) {
    return l + rand() % (r - l + 1);
}

ll rdd(ll ss) {
    vector<ll> digit;
    ff(i, 1, ss) {
        ll k = rand() % 10;
        //cerr << k << endl;
        digit.push_back(k);
    }
    ll ans = 0, power = 1;
    for(ll x : digit) {
        ans += x * power;
        power *= 10;
    }
    return ans;
}

ll smr(ll l, ll r) {
    ll x1 = (r * (r + 1)) / 2;
    l--;
    ll x2 = (l * (l + 1)) / 2;
    return x1 - x2;
}

ll spow(ll a, ll b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    ll k = spow(a, b / 2);
    k = (k * k) % mod;
    if (b % 2) k *= a;
    k %= mod;
    return k;
}

//MAIN PROGRAM----
//----------------
//---------------------

ll N, K;

void pre_process(){

}

void solve() {
    cin >> N >> K;
    if (K % 3 != 0) {
        if (N % 3 == 0) valrtn("Bob");
        valrtn("Alice");
    }
    else {
        if (N % (K + 1) == 0) valrtn("Bob");
        N %= (K + 1);
        if (N % 3 == 0 && N % K != 0) valrtn("Bob");
        valrtn("Alice");
    }
}

bool mem1;

Get1700rate{
    pre_process();
    fastIO;
    srand(time(NULL));
    
    bool multi_test_case = 1;
    ll t = 1;
    if (multi_test_case) cin>>t;
    
    ff(____,1,t) {
        //cout<<"Case "<<____<<":"<<endl;
        //cerr<<"Case "<<____<<endl;
        solve();
    }
    
    //eren;
    //cerr << "Memory Cost: " << abs(&mem1-&mem2)/1024./1024. << " MB" << endl;
    //cerr << "Time Cost: " << clock()*1000./CLOCKS_PER_SEC << " MS" << endl;
}


Comments

Submit
0 Comments
More Questions

1302. Deepest Leaves Sum
1209. Remove All Adjacent Duplicates in String II
994. Rotting Oranges
983. Minimum Cost For Tickets
973. K Closest Points to Origin
969. Pancake Sorting
967. Numbers With Same Consecutive Differences
957. Prison Cells After N Days
946. Validate Stack Sequences
921. Minimum Add to Make Parentheses Valid
881. Boats to Save People
497. Random Point in Non-overlapping Rectangles
528. Random Pick with Weight
470. Implement Rand10() Using Rand7()
866. Prime Palindrome
1516A - Tit for Tat
622. Design Circular Queue
814. Binary Tree Pruning
791. Custom Sort String
787. Cheapest Flights Within K Stops
779. K-th Symbol in Grammar
701. Insert into a Binary Search Tree
429. N-ary Tree Level Order Traversal
739. Daily Temperatures
647. Palindromic Substrings
583. Delete Operation for Two Strings
518. Coin Change 2
516. Longest Palindromic Subsequence
468. Validate IP Address
450. Delete Node in a BST